package com.batsoft.trade.model.transaction;

import com.batsoft.trade.model.common.HandleType;
import lombok.Getter;

/**
 * @author <a href="mailto:hellohesir@gmail.com">Mr_He</a>
 * 2019/5/14 00:28
 * 交易类型
 */
public enum ContractType implements HandleType {
    //买入开多
    BUY_OPEN_MORE(1, "买入开多"),   //买入      建仓
    //卖出开空
    SELL_OPEN_EMPTY(2, "卖出开空"), //卖出      建仓
    //卖出平多
    SELL_FLAT_MORE(3, "卖出平多"),  //平卖变买  清仓
    //买入平空
    BUY_FLAT_EMPTY(4, "买入平空"),  //平买变卖  清仓
    ;

    ContractType(Integer value, String remark) {
        this.value = value;
        this.remark = remark;
    }

    @Getter
    private Integer value;

    @Getter
    private String remark;

    public static ContractType getByValue(Integer value) {
        for (ContractType type : ContractType.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        throw new RuntimeException("cannot type .....");
    }

}
